#include "AloneTorque.h"

#include "AniVector3.h"
#include "DemagVector3.h"
#include "HThermVector3.h"
#include "AppliedFieldVector3.h"
#include "Constants.h"

#include <cmath>
#include <iostream>

AloneTorque::AloneTorque(Clock clock,Pulse *field,Layer layer)
{
  newGamma=Constants::GAMMA/(1+pow(layer.getAlpha(),2));
  newAlpha=newGamma*layer.getAlpha();
  Vector3 torque1,torque2;
  heff=AniVector3(layer);
  //std::cout<<"ani="<<heff.getX()<<"=="<<heff.getY()<<"=="<<heff.getZ()<<std::endl;
  heff.add(DemagVector3(layer));
  //std::cout<<"+demag="<<heff.getX()<<"=="<<heff.getY()<<"=="<<heff.getZ()<<std::endl; 
 //heff.add(HThermVector3(mag));
  heff.add(AppliedFieldVector3(clock,field));
  //std::cout<<"+applied="<<heff.getX()<<"=="<<heff.getY()<<"=="<<heff.getZ()<<std::endl;
  torque1=layer.getMag();
  torque1.crossProduct(heff);
  torque2=layer.getMag();
  torque2.crossProduct(torque1);
  torque1.mult(-newGamma);
  torque2.mult(-newAlpha);
  torque1.add(torque2);
  x=torque1.getX();
  y=torque1.getY();
  z=torque1.getZ();
  //std::cout<<x<<"=="<<y<<"=="<<z<<std::endl;
}

AloneTorque::~AloneTorque()
{

}

//didn't take Htherm into account

